﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace SfsTools.Core
{
    /// <summary>
    /// Represents a deleted directory entry.
    /// </summary>
    internal class DeletedDirectoryEntry : BaseDirectoryEntry
    {
        #region Methods

        /// <summary>
        /// Accepts a visitor.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        [DebuggerStepThrough]
        public override void AcceptVisitor(IIndexEntryVisitor visitor)
        {
            visitor.VisitDeletedDirectory(this);
        }

        /// <summary>
        /// Creates a new <see cref="DeletedDirectoryEntry"/> and initializes the underlying buffer.
        /// </summary>
        /// <param name="position">The position of this entry on the volume.</param>
        /// <returns>A new <see cref="DeletedDirectoryEntry"/> instance.</returns>
        [DebuggerStepThrough]
        public static DeletedDirectoryEntry Create(long position)
        {
            byte[] buffer = new byte[64];
            buffer[0] = 0x19;
            return new DeletedDirectoryEntry(position, buffer);
        }

        #endregion

        #region Constructors
        /// <overloads>Initializes a new instance of <see cref="DeletedDirectoryEntry"/>.</overloads>
        /// <summary>
        /// Initializes a new instance of <see cref="DeletedDirectoryEntry"/>.
        /// </summary>
        /// <param name="position">The position of this entry on the volume.</param>
        /// <param name="buffer">The buffer.</param>
        [DebuggerStepThrough]
        public DeletedDirectoryEntry(Int64 position, byte[] buffer)
            : base(position, buffer)
        {
        }
        /// <summary>
        /// Initializes a new instance of <see cref="DeletedDirectoryEntry"/>.
        /// </summary>
        /// <param name="entry">The instance to copy from.</param>
        /// <exception cref="ArgumentNullException">The argument <paramref name="entry"/> is <see langword="null"/>.</exception>
        [DebuggerStepThrough]
        public DeletedDirectoryEntry(PresentDirectoryEntry entry)
            : base(entry)
        {
            FBuffer[0] = 0x19;
        }
        #endregion
    }
}
